Tmem fails to put_domain so a dying domain never gets
properly shut down. Also, fix race condition when
domain is dying by not allowing any new ops to succeed.
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
DUP_START_CYC_COUNTER(flush,succ_get);
DUP_START_CYC_COUNTER(flush_obj,succ_get);
+ if ( client != NULL && tmh_client_is_dying(client) )
+ {
+ rc = -ENODEV;
+ goto out;
+ }
+
if ( unlikely(tmh_get_tmemop_from_client(&op, uops) != 0) )
{
printk("tmem: can't get tmem struct from %s\n",client_str);
if ( client == NULL )
return;
+ if ( !tmh_client_is_dying(client) )
+ {
+ printk("tmem: tmem_destroy can only destroy dying client\n");
+ return;
+ }
+
if ( tmh_lock_all )
spin_lock(&tmem_spinlock);
else
#ifndef __i386__
xmem_pool_destroy(tmh->persistent_pool);
#endif
+ put_domain(tmh->domain);
xfree(tmh);
}
/* this appears to be unreliable when a domain is being shut down */
static inline struct client *tmh_client_from_cli_id(cli_id_t cli_id)
{
- struct domain *d = get_domain_by_id(cli_id);
+ struct domain *d = get_domain_by_id(cli_id); /* incs d->refcnt! */
if (d == NULL)
return NULL;
return (struct client *)(d->tmem);
return (struct client *)(current->domain->tmem);
}
+#define tmh_client_is_dying(_client) (!!_client->tmh->domain->is_dying)
+
static inline cli_id_t tmh_get_cli_id_from_current(void)
{
return current->domain->domain_id;